package com.tongji.admin.view
{
	import com.tongji.admin.event.CantavilAdminEvent;
	import com.tongji.admin.vo.Cantavil;
	
	import flash.events.MouseEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/7/
	 */ 
	public class CantavilAdminMediator extends Mediator
	{
		[Inject]
		public var view:CantavilAdminView;
		
		override public function onRegister():void
		{
			view.cantavilBtnGroup.addBtn.addEventListener(MouseEvent.CLICK, addCantavilHandler);
		}
		
		private function addCantavilHandler(event:MouseEvent):void
		{
			var cantavil:Cantavil = new Cantavil();
			cantavil.cantavilAddress = view.cantavilAddressTX.text;
			cantavil.cantavilCreateDate = new Date();
			cantavil.cantavilCreator = "caddy";
			cantavil.cantavilDeveloper = view.cantavilDeveloperTX.text;
			cantavil.cantavilName = view.cantavilNameTX.text;
			cantavil.cantavilRemark = view.cantavilRemarkTX.text;
			cantavil.cantavilType = null;
			cantavil.developDesc = view.developDescTX.text;
			cantavil.typeID = 1;
			
			dispatch(new CantavilAdminEvent(CantavilAdminEvent.ADD_A_CANTAVIL, cantavil));
		}
	}
}